home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
super.arc
/
SUPER.DOC
< prev
next >
Wrap
Text File
|
1986-06-13
|
11KB
|
282 lines
SUPERCOMM
IBM PC Communications drivers
(C) Copyright 1986
Doctor Debug
Pittsburgh, Pa
All Rights Reserved
****************************************************************
* *
* As with all the Doctor's software, SUPERCOMM *
* has been tested and by all indications works *
* as described under all reasonable conditions. *
* However, the good doctor cannot be responsible *
* for damages, heartbreak, outbreaks of war or *
* acts of God caused by the use of this *
* software. As it is FreeWare, *free* *
* distribution is encouraged so long as the *
* programs and documentation are unaltered. *
* Please read the contribution information at *
* the end of this document. *
* *
****************************************************************
Anyone who has attempted to use the BIOS Int 14 to access
the IBM's Communications ports knows that these routines are the
pits. They allow absolutely no flexibility, and also no
interrupt-driven means of reading the ports. SUPERCOMM is an
answer to that problem.
Running the program SUPER.COM is necessary to access
SUPERCOMM. This program can easily be placed in your AUTOEXEC
file if you wish. Part of the program stays resident, replacing
Interrupt 14.
After SUPER.COM has been run, the following functions are
available to the new interrupt 14. As with the BIOS interrupt,
select the function by loading AH with the function number.
Function 0 - set Communications status
Unchanged from the BIOS Int 14. Does not activate SUPERCOMM.
This is really just kept for compatability sake.
Function 1 - Transmit Byte
A bug which caused this function not to work with some
modems has been fixed, but otherwise this function is the same as
the BIOS function.
Function 2 - Receive Character
Removes a character from the circular input buffer and
returns it in AL. If no character is available a timeout occurs
(bit 7 of AH will be set.)
Function 3 - Port Status
Unchanged.
Function 4 - Clear Buffer
Empties Communications input buffer. (The buffer is 4K in
length)
Function 5 - Block Receive
Requests a block of data be read from the comm port.
ENTRY: DX = Port (0 or 1)
CX = Size of block in bytes
ES:BX= address to which data will be written
RETURN: CX = 16 bit checksum of data read
AL = Error codes (as in original Int 14)
Function 6 - Block Send
Sends a block of data over the comm line
ENTRY: DX = Port (0 or 1)
CX = Size of block in bytes
ES:BX= Address of block
RETURN: AL = Error codes (as in original Int 14)
Function 7 - Buffer Status
Number of bytes waiting in the buffer returned in BX
Function 8 - Get Character
Equivalent of INKEY from keyboard. Gets a byte from the
input buffer if one is waiting. Byte is returned in AL. If no
byte was waiting, AL will have 0. Don't use this function for
data which might be 0.
Function 9 - Set Port
Port in DX (0 or 1) will be buffered and used by SUPERCOMM.
The other will be handled by the old BIOS routines.
Function 12 - Open SUPERCOMM port
Load registers as in old Interrupt 14's Function 0. Port
specified in DX becomes active SUPERCOMM port. System interrupt
speed is kicked up to 4550 times/sec for goof-proof buffering of
incoming data. This function must be called before any of the
input or output functions are. While the SUPERCOMM port is open
overall system speed may lag as much as 35%, so be sure to close
the port (using function 13) when you are through. Leaving the
port open at the end of a user program may cause a crash when
another program is loaded.
Function 13 - Close SUPERCOMM port
Simply load the port (0 or 1) into DX and call this routine.
System interrupt speed is returned to normal and SUPERCOMM is
deactivated until the next Function 12.
Function 14 - Peek buffer
This handy function returns the next character in the input
buffer in AL, but does not remove the character from the buffer.
This means you can look ahead one char into the buffer. If no
characters are waiting AL will return with a 0.
SUPERCOMM returns error codes in AH and AL (unless they are
returning other information). These error codes will be the same
as those returned by the standard Input/Output routines of the
old Interrupt 14.
All this is pretty complicated, which is why I have included
the file SUPERCOM.PAS, which contains turbo Pascal routines which
access these functions. DUMBTERM.PAS is a demonstration program
which is essentially a plain vanilla comm program. Examining
these programs will provide some insight into how SUPERCOMM
works. Be sure to compile any Turbo programs using SUPERCOMM to a
.COM file before using! DUMBTERM.COM has been included for those
out there without a Turbo Pascal Compiler. Also included is
DUMB.ASM and DUMB.COM, which are essentially the same thing as
DUMBTERM.PAS only in 8086 assembler.
Pascal Routines
(Found in SUPERCOM.PAS)
These routines are meant to be called by user programs. The
SUPER.COM Interrupt 14 driver must have been installed to
use any of these routines. Use of these routines without proper
installation of SUPER.COM will produce unpredictable results.
It should be relatively simple to translate these turbo routines
into C or most any other language.
The integers InError and OutError will always contain the error
conditions after every receive or transmit. The bits of these
values are defined as:
Bit 7 (128) Timeout
Bit 3 (8) Framing Error
Bit 2 (4) Parity Error
Bit 1 (2) Overrun Error
If the value of InError[port] is 0, then you can be sure that the
last character was received without error.
The value or Port is always 1 or 2.
Procedure InitPort(port,Baud,Parity,data_bits,stop_bits)
Baud: integer 300-9600
Parity: char, E(ven),O(dd),N(one)
Data_bits: integer, 7 or 8
Stop_bits: integer, 1 or 2
This routine initializes the communications port
to the parameters specified and activates SUPERCOM
for that port. All of the following functions will
use the port specified here.
Function PortStatus(port)
This function returns the line status and modem control
status of the comm port specified. The bits returned are
defined as:
Bit 15 (negative) Time out (no device connected)
Bit 14 (16384) Transmission shift register empty
Bit 13 (8192) Transmission holding register empty
Bit 12 (4096) Break detect
Bit 11 (2048) Framing error
Bit 10 (1024) Parity error
Bit 9 (512) Overrun error
Bit 8 (256) Data ready
Bit 7 (128) Received line signal detect
Bit 6 (64) Ring indicator
Bit 5 (32) Data set ready
Bit 4 (16) Clear to send
Bit 3 (8) Delta receive line signal detect
Bit 2 (4) Trailing edge ring detector
Bit 1 (2) Delta data set ready
Bit 0 (1) Delta clear to send
Procedure XmitCh(ch)
This Procedure sends the character in ch out the port
specified.
Procedure XmitBlk(string)
This procedure sends the entire string out the comm port.
Procedure XmitLn(string)
This is identical to XmitBlk, but adds a CR/LF to the
end of the block.
Procedure RecCh(ch)
This procedure waits until a character is available over
the comm line and then returns it in ch. If the system times
out ch will contain a nul (Ascii 0).
Procedure RecLn(string)
This is the equivalent of ReadLn over the comm port.
Be sure to check the InError variable to make sure the
operation did not time out (no CR was received.)
Procedure RecBlk(number,String)
The number of characters specified by number will be
placed into the string. Be sure to check the InError
variable to assure that the operation did not time out
before sufficient characters were received.
Procedure GrabCh(ch)
If a character is waiting in the receive buffer it will
be returned in ch otherwise ch will contain a nul character.
Procedure PeekBuff(ch)
Identical to GrabCh but the character is not removed
from the buffer.
Procedure ClearBuff
Empties the receive buffer
Procedure ClosePort
Closes the comm port and deactivates SUPERCOMM until the
next InitPort.
Function Rlen
Returns the number of characters currently available in the
receive buffer.
Summary
(How to use SUPERCOMM in a few semi-easy steps)
1) Make sure that SUPER.COM has been run so that SUPERCOMM is
resident. It is very difficult for software to work properly when
in is not in the computer's memory.
2) Your program should first issue an Interrupt 14 with AH set
to 12 (opens the port with SUPERCOMM) and the other registers set
as in the old BIOS Interrupt 14 Function 0. This assures that
SUPERCOMM is humming away, busily checking comm activity on the
port specified in DX some 4500 times a second.
3) Now you can use functions 1 through 8 to input of output
all the happy data over that comm port.
4) Before exiting the program, issue an Interrupt 14 with AH set
to 13 (close SUPERCOMM port). This assures that all is back to
normal for any programs which you run later.
Believe me, using it is a great deal more simple than
writing it was!
If you have questions, comments, suggestions or criticisms,
you can reach me on the Neverboard, (412) 733-4842 1200/8/N. If
you find SUPERCOMM useful, a donation of, say, $15 may be sent to
the doctor's office:
Doctor Debug
1 Windsor Road B-6
Pittsburgh, PA 15239
If you use these routines in a commercial product, the above
donation is **not** optional. The donation will make sure that
you are informed of upgrades and other pieces of the doctor's
software.